﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Redis
{

    /// <summary>
    /// 服务器配置
    /// </summary>
    public class ServerConfig
    {
        /// <summary>
        /// 创建一个服务器配置
        /// </summary>
        /// <param name="_host">IP</param>
        /// <param name="_port">端口</param>
        public ServerConfig(String _host,String _port)
        {
            Host = _host;
            Port = _port;
            ConnectionString = String.Format("{0}:{1}", Host, Port);
        }
        /// <summary>
        /// 创建一个服务器配置
        /// </summary>
        /// <param name="_connectstring">连接串例:[127.0.0.1:6379]</param>
        public ServerConfig(String _connectstring )
        {
            ConnectionString = _connectstring;
            var s = ConnectionString.Split(':');
            Host = s[0];
            Port = s[1];
        }
        /// <summary>
        /// 连接串
        /// </summary>
        public String ConnectionString
        {
            get;
            private set;
        }
        /// <summary>
        /// IP
        /// </summary>
        public String Host { get; private set; }
        /// <summary>
        /// 端口
        /// </summary>
        public String Port { get; private set; }
        /// <summary>
        /// 连接密码
        /// </summary>
        public String Password { get; set; }
    }



    /// <summary>
    /// Redis初始化配置
    /// </summary>
    public class RedisConfig
    {
        public RedisConfig()
        {
            ReadOnlyHosts = new List<ServerConfig>();
            ReadWirteHost = new List<ServerConfig>();
            MaxWritePoolSize = 5;
            MaxReadPoolSize = 5;
        }

        /// <summary>
        /// 写连接池大小
        /// </summary>
        public Int32 MaxWritePoolSize { get; set; }
        /// <summary>
        /// 读连接池大小
        /// </summary>
        public Int32 MaxReadPoolSize { get; set; }
        /// <summary>
        /// 只读服务器列表
        /// </summary>
        public List<ServerConfig> ReadOnlyHosts { get; set; }
        /// <summary>
        /// 可读可写服务器列表
        /// </summary>
        public List<ServerConfig> ReadWirteHost { get; set; }

    }
}
